package main

/*
#include <stdio.h>
#include <stdlib.h>
void print_hello(const char *name) {
printf("Hello %s!\n", name);
}
*/
import "C"
import "unsafe"

//If your application, or one of the libraries that you rely upon, was written with the C
//language (or one of its derivatives, such as C++ or Objective-C) for specific reasons
//and you’re not able to move it to Go, then CGo is an invaluable feature. Using this
//functionality, it is possible to include C code directly, or call out to other C-based
//functionality. It is important to use this carefully—there are some performance impacts
//in making the jump from one language to another—but more significantly you need to
//remember about memory management and threading in a way that Go would normally
//manage for you.

func main() {
	cName := C.CString("world")
	C.print_hello(cName)
	C.free(unsafe.Pointer(cName))
}
